package com.bailiban.controller;

import com.bailiban.entity.Product;
import com.bailiban.service.ProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * (Product)表控制层
 *
 * @author zhulang
 * @since 2020-10-19 11:31:51
 */
@Controller
@RequestMapping("product")
public class ProductController {
    /**
     * 服务对象
     */
    @Resource
    private ProductService productService;

    /**
     * 查询所有产品
     *
     * @return
     */
    @GetMapping("findAll")
    public ModelAndView findAll(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "3") Integer size) {
        PageInfo<Product> pageInfo = productService.findAll(page, size);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("product-list");
        modelAndView.addObject("listP", pageInfo);
        return modelAndView;
    }

}